package com.siyu.prewarn.skreservoirdutyperson.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siyu.prewarn.skreservoirdutyperson.domain.SkReservoirDutyPerson;
import com.siyu.prewarn.skreservoirdutyperson.service.ISkReservoirDutyPersonService;

/**
 * 水库责任人基础信息Controller
 *
 * @author hrhy
 * @date 2024-06-27
 */
@RestController
@RequestMapping("/prewarn/SkReservoirDutyPerson")
public class SkReservoirDutyPersonController extends BaseController {
    @Autowired
    private ISkReservoirDutyPersonService skReservoirDutyPersonService;

    /**
     * 查询水库责任人基础信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SkReservoirDutyPerson skReservoirDutyPerson) {
        startPage();
        List<SkReservoirDutyPerson> list = skReservoirDutyPersonService.selectSkReservoirDutyPersonList(skReservoirDutyPerson);
        return getDataTable(list);
    }

    /**
     * 导出水库责任人基础信息列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, SkReservoirDutyPerson skReservoirDutyPerson) {
        List<SkReservoirDutyPerson> list = skReservoirDutyPersonService.selectSkReservoirDutyPersonList(skReservoirDutyPerson);
        ExcelUtil<SkReservoirDutyPerson> util = new ExcelUtil<SkReservoirDutyPerson>(SkReservoirDutyPerson.class);
        util.exportExcel(response, list, "水库责任人基础信息数据");
    }

    /**
     * 获取水库责任人基础信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(skReservoirDutyPersonService.selectSkReservoirDutyPersonById(id));
    }

    /**
     * 新增水库责任人基础信息
     */
    @PostMapping
    public AjaxResult add(@RequestBody SkReservoirDutyPerson skReservoirDutyPerson) {
        return toAjax(skReservoirDutyPersonService.insertSkReservoirDutyPerson(skReservoirDutyPerson));
    }

    /**
     * 修改水库责任人基础信息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody SkReservoirDutyPerson skReservoirDutyPerson) {
        return toAjax(skReservoirDutyPersonService.updateSkReservoirDutyPerson(skReservoirDutyPerson));
    }

    /**
     * 删除水库责任人基础信息
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(skReservoirDutyPersonService.deleteSkReservoirDutyPersonByIds(ids));
    }
}
